﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TomNet.IMSC.Core.Contracts.Account;
using TomNet.IMSC.Core.Contracts.Decoration;
using TomNet.IMSC.Core.Contracts.Finance;
using TomNet.IMSC.Core.Contracts.LowPriceHouse;
using TomNet.IMSC.Core.Contracts.NewHouse;
using TomNet.IMSC.Core.Contracts.Organization;
using TomNet.IMSC.Model.ViewModels.Account;
using TomNet.IMSC.Web.Filters;
using TomNet.Web.Mvc;
using TomNet.Web.Mvc.Security;
using TomNet.Web.Mvc.UI;

namespace TomNet.IMSC.Web.Areas.Account.Controllers
{
    [Description("财务-工资")]
    [GlobalAuthorization]
    public class SalaryController : BaseController
    {
        public IBrokerageRunningsContract BContract { set; get; }// 佣金流水
        public IStaffContract SContract { get; set; }
        public INewHouseRunningsContract NHContract { get; set; }
        public ILowPriceHouseRunningsContract LPHContract { get; set; }
        public IDecorationRunningsContract DContract { get; set; }
        public IFinanceRunningsContract FContract { get; set; }
        public IBrokerageSettleAccountsRunningsContract BSContract { get; set; }
        public IBuildingsBrokerageLevelContract BBLContract { get; set; }
        public IBuildingsBrokerageGroupContract BBGContract { get; set; }
        public IDecorationCompanyBrokerageLevelContract DBLContract { get; set; }
        public IDecorationCompanyBrokerageGroupContract DBGContract { get; set; }
        public IBrokerageTypeContract BTContract { get; set; }
        public ISalaryContract SaContract { get; set; }
        public IExpensesRunningsContract EContract { set; get; }// 费用流水

        [Description("财务-工资列表面页")]
        [GlobalAuthorization]
        public ActionResult SalaryList(int ModuleID, int UserTypeID)
        {
            ViewBag.ModuleID = ModuleID;
            ViewBag.UserTypeID = UserTypeID;
            return View();
        }

        [Description("财务-获得工资列表数据")]
        [HttpPost, AjaxOnly]
        public ActionResult SalaryListAsync(int pageIndex, int pageSize, int ModuleID, string State, int UserTypeID, string Search, string BeginTime, string EndTime)//, string search = "", int depid
        {
            IQueryable<SalaryListModel> query = Enumerable.Empty<SalaryListModel>().AsQueryable();
            DateTime bt = Convert.ToDateTime(BeginTime);
            DateTime et = Convert.ToDateTime(EndTime).AddDays(1);
            var cookies = Common.CookiesManagement.GetCookies();
            var ticket = Common.CookiesManagement.GetTicket(cookies);
            var model = Common.CookiesManagement.GetLoginModel(ticket);
            switch (ModuleID)
            {
                case 1:
                    query = from sa in SaContract.Entities
                            join n in NHContract.Entities on sa.RunningsID equals n.Id
                            join u1 in SContract.Entities on n.OriginStaffID equals u1.Id into eu1
                            from eu1d in eu1.DefaultIfEmpty()
                            join u2 in SContract.Entities on n.SellStaffID equals u2.Id into eu2
                            from eu2d in eu2.DefaultIfEmpty()
                            where sa.ModuleID == ModuleID && sa.UserTypeID == UserTypeID && n.SubscribeTime >= bt && n.SubscribeTime <= et
                            select new SalaryListModel
                            {
                                AgentID = n.AgentID,
                                Amount = sa.Amount,//sa.State == 1 ? sa.Amount : BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 1).FirstOrDefault().Amount + BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 2).FirstOrDefault().Amount - BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 3).FirstOrDefault().Amount - BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 4).FirstOrDefault().Amount,
                                MinAmount = sa.MinAmount,
                                CompanyBonus = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 2).FirstOrDefault().Amount,
                                CompanyBrokerage = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 1).FirstOrDefault().Amount,
                                CustomerName = n.CustomerName,
                                CustomerPhone = n.CustomerPhone,
                                Expenses = EContract.Entities.Count(p => p.ModuleID == sa.ModuleID && p.RunningsID == sa.RunningsID && (p.State == 2 || p.State == 4)) > 0 ? EContract.Entities.Where(p => p.ModuleID == sa.ModuleID && p.RunningsID == sa.RunningsID && (p.State == 2 || p.State == 4)).Sum(p => p.Amount) : 0,
                                Id = sa.Id,
                                IntermediaryBrokerage = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 3).FirstOrDefault().Amount,
                                IntermediaryName = n.IntermediaryName,
                                ItemName = n.BuildingName,
                                ItemPrice = n.TotalPrice,
                                ModuleID = ModuleID,
                                Percentage = sa.Percentage,
                                Remark = sa.Remark,
                                ReturnRate = sa.ReturnRate,
                                RunningsID = sa.RunningsID,
                                SalaryDate = sa.SalaryDate,
                                StaffID = sa.UserTypeID == 1 ? n.OriginStaffID : n.SellStaffID,
                                StaffName = sa.UserTypeID == 1 ? eu1d.Name : eu2d.Name,
                                State = sa.State,
                                TaxRate = sa.TaxRate,
                                UserBrokerage = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 4).FirstOrDefault().Amount,
                                UserName = n.UserName,
                                UserTypeID = sa.UserTypeID
                            };
                    break;
                case 2:
                case 3:
                    query = from sa in SaContract.Entities
                            join n in LPHContract.Entities on sa.RunningsID equals n.Id
                            join u1 in SContract.Entities on n.OriginStaffID equals u1.Id into eu1
                            from eu1d in eu1.DefaultIfEmpty()
                            join u2 in SContract.Entities on n.SellStaffID equals u2.Id into eu2
                            from eu2d in eu2.DefaultIfEmpty()
                            join u3 in SContract.Entities on n.StationedStaffID equals u3.Id into eu3
                            from eu3d in eu2.DefaultIfEmpty()
                            where sa.ModuleID == ModuleID && sa.UserTypeID == UserTypeID && n.SubscribeTime >= bt && n.SubscribeTime <= et
                            select new SalaryListModel
                            {
                                AgentID = n.AgentID,
                                Amount = sa.Amount,//sa.State == 1 ? sa.Amount : BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 1).FirstOrDefault().Amount + BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 2).FirstOrDefault().Amount - BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 3).FirstOrDefault().Amount - BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 4).FirstOrDefault().Amount,
                                MinAmount = sa.MinAmount,
                                CompanyBonus = 0,
                                CompanyBrokerage = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 6).FirstOrDefault().Amount,
                                CustomerName = n.CustomerName,
                                CustomerPhone = n.CustomerPhone,
                                Expenses = EContract.Entities.Count(p => p.ModuleID == sa.ModuleID && p.RunningsID == sa.RunningsID && (p.State == 2 || p.State == 4)) > 0 ? EContract.Entities.Where(p => p.ModuleID == sa.ModuleID && p.RunningsID == sa.RunningsID && (p.State == 2 || p.State == 4)).Sum(p => p.Amount) : 0,
                                IntermediaryBrokerage = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 7).FirstOrDefault().Amount,
                                IntermediaryName = n.IntermediaryName,
                                ItemName = n.BuildingName,
                                ItemPrice = n.LowPrice,
                                ModuleID = ModuleID,
                                Percentage = sa.Percentage,
                                Remark = sa.Remark,
                                ReturnRate = sa.ReturnRate,
                                RunningsID = sa.RunningsID,
                                SalaryDate = sa.SalaryDate,
                                StaffID = sa.UserTypeID == 1 ? n.OriginStaffID : (sa.UserTypeID == 2 ? n.SellStaffID : n.StationedStaffID),
                                StaffName = sa.UserTypeID == 1 ? eu1d.Name : (sa.UserTypeID == 2 ? eu2d.Name : eu3d.Name),
                                State = sa.State,
                                TaxRate = sa.TaxRate,
                                UserBrokerage = 0,
                                UserName = n.UserName,
                                UserTypeID = sa.UserTypeID
                            };
                    break;
                case 4:
                    query = from sa in SaContract.Entities
                            join n in DContract.Entities on sa.RunningsID equals n.Id
                            join u1 in SContract.Entities on n.OriginStaffID equals u1.Id into eu1
                            from eu1d in eu1.DefaultIfEmpty()
                            join u2 in SContract.Entities on n.SellStaffID equals u2.Id into eu2
                            from eu2d in eu2.DefaultIfEmpty()
                            where sa.ModuleID == ModuleID && sa.UserTypeID == UserTypeID && n.SubscribeTime >= bt && n.SubscribeTime <= et
                            select new SalaryListModel
                            {
                                AgentID = n.AgentID,
                                Amount = sa.Amount,//sa.State == 1 ? sa.Amount : BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 1).FirstOrDefault().Amount + BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 2).FirstOrDefault().Amount - BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 3).FirstOrDefault().Amount - BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 4).FirstOrDefault().Amount,
                                MinAmount = sa.MinAmount,
                                CompanyBonus = 0,
                                CompanyBrokerage = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 9).FirstOrDefault().Amount,
                                CustomerName = n.CustomerName,
                                CustomerPhone = n.CustomerPhone,
                                Expenses = EContract.Entities.Count(p => p.ModuleID == sa.ModuleID && p.RunningsID == sa.RunningsID && (p.State == 2 || p.State == 4)) > 0 ? EContract.Entities.Where(p => p.ModuleID == sa.ModuleID && p.RunningsID == sa.RunningsID && (p.State == 2 || p.State == 4)).Sum(p => p.Amount) : 0,
                                Id = sa.Id,
                                IntermediaryBrokerage = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 10).FirstOrDefault().Amount,
                                IntermediaryName = n.IntermediaryName,
                                ItemName = n.DecorationCompanyName,
                                ItemPrice = n.TotalPrice,
                                ModuleID = ModuleID,
                                Percentage = sa.Percentage,
                                Remark = sa.Remark,
                                ReturnRate = sa.ReturnRate,
                                RunningsID = sa.RunningsID,
                                SalaryDate = sa.SalaryDate,
                                StaffID = sa.UserTypeID == 1 ? n.OriginStaffID : n.SellStaffID,
                                StaffName = sa.UserTypeID == 1 ? eu1d.Name : eu2d.Name,
                                State = sa.State,
                                TaxRate = sa.TaxRate,
                                UserBrokerage = 0,
                                UserName = n.UserName,
                                UserTypeID = sa.UserTypeID
                            };
                    break;
                case 5:
                    query = from sa in SaContract.Entities
                            join n in FContract.Entities on sa.RunningsID equals n.Id
                            join u1 in SContract.Entities on n.TransactStaffID equals u1.Id into eu1
                            from eu1d in eu1.DefaultIfEmpty()
                            join u2 in SContract.Entities on n.SellStaffID equals u2.Id into eu2
                            from eu2d in eu2.DefaultIfEmpty()
                            where sa.ModuleID == ModuleID && sa.UserTypeID == UserTypeID && n.FilingTime >= bt && n.FilingTime <= et
                            select new SalaryListModel
                            {
                                AgentID = n.AgentID,
                                Amount = sa.Amount,//sa.State == 1 ? sa.Amount : BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 1).FirstOrDefault().Amount + BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 2).FirstOrDefault().Amount - BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 3).FirstOrDefault().Amount - BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 4).FirstOrDefault().Amount,
                                MinAmount = sa.MinAmount,
                                CompanyBonus = 0,
                                CompanyBrokerage = 0,
                                CustomerName = n.CustomerName,
                                CustomerPhone = n.CustomerPhone,
                                Expenses = EContract.Entities.Count(p => p.ModuleID == sa.ModuleID && p.RunningsID == sa.RunningsID && (p.State == 2 || p.State == 4)) > 0 ? EContract.Entities.Where(p => p.ModuleID == sa.ModuleID && p.RunningsID == sa.RunningsID && (p.State == 2 || p.State == 4)).Sum(p => p.Amount) : 0,
                                Id = sa.Id,
                                IntermediaryBrokerage = BContract.Entities.Where(p => p.RunningsID == sa.RunningsID && p.ModuleID == sa.ModuleID && p.BrokerageTypeID == 12).FirstOrDefault().Amount,
                                IntermediaryName = n.IntermediaryName,
                                ItemName = n.FinanceItemsName,
                                ItemPrice = n.Price,
                                ModuleID = ModuleID,
                                Percentage = sa.Percentage,
                                Remark = sa.Remark,
                                ReturnRate = sa.ReturnRate,
                                RunningsID = sa.RunningsID,
                                SalaryDate = sa.SalaryDate,
                                StaffID = sa.UserTypeID == 1 ? n.TransactStaffID : n.SellStaffID,
                                StaffName = sa.UserTypeID == 1 ? eu1d.Name : eu2d.Name,
                                State = sa.State,
                                TaxRate = sa.TaxRate,
                                UserBrokerage = 0,
                                UserName = n.UserName,
                                UserTypeID = sa.UserTypeID
                            };
                    break;
                default:
                    break;
            }
            //if (State > 0)// 状态  0未开    1已开
            //{
            string[] s = State.Split(',');
            query = query.Where(p => s.Contains(p.State.ToString()));
            //}
            if (model.AgentId != 0)
            {
                query = query.Where(p => p.AgentID == model.AgentId);
            }
            if (!String.IsNullOrEmpty(Search))
            {
                query = query.Where(p => p.ItemName.IndexOf(Search) != -1 || p.IntermediaryName.IndexOf(Search) != -1 || p.UserName.IndexOf(Search) != -1 || p.CustomerName.IndexOf(Search) != -1 || p.CustomerPhone.IndexOf(Search) != -1);
            }

            var total = query.Count();

            //默认给一个排序的字段
            query = query.OrderByDescending(m => m.Id);

            //分页(假如total == 0，则取消分页查询，提高性能)
            query = total > 0 ? query.Skip((pageIndex - 1) * pageSize).Take(pageSize)
                : null;

            List<SalaryListModel> ql = new List<SalaryListModel>();
            if (total > 0)
            {
                ql = query.ToList();
                foreach (var item in ql.Where(p => p.State == 0))
                {
                    item.Amount = ((item.CompanyBrokerage + item.CompanyBonus - (item.IntermediaryBrokerage * (1 - item.ReturnRate)) - item.UserBrokerage - item.Expenses) * (1 - item.TaxRate) * item.Percentage);
                    if (item.Amount < item.MinAmount)
                    {
                        item.Amount = item.MinAmount;
                    }
                }
            }
            GridData<object> gridData = total > 0 ? new GridData<object>() { Total = total, Rows = ql } : new GridData<object>() { Total = total, Rows = new List<string>() };

            return JsonEx(gridData, JsonRequestBehavior.AllowGet, "yyyy-MM");
        }

        [Description("财务-修改工资数据")]
        [HttpPost, AjaxOnly]
        public ActionResult ModifySalaryDataAsync(int type ,string data,string IDs)//, string search = "", int depid
        {
            //所有AJAX的结果，返回统一数据格式
            var result = new AjaxResult();
            try
            {
                if (type == 5)
                {
                    DateTime a = Convert.ToDateTime(data);
                }
                else
                {
                    decimal d = Convert.ToDecimal(data);
                }
            }
            catch (Exception)
            {
                result.Type = AjaxResultType.Error;
                result.Content = "输入格式不正确";
                return JsonEx(result);
            }
            try
            {
                string[] ids = IDs.Split(',');
                int count = 0;
                switch (type)
                {
                    case 1://修改返点
                        count = SaContract.UpdateDirect(p => ids.Contains(p.Id.ToString()), p => new Model.DbModels.Account.Salary { ReturnRate = Convert.ToDecimal(data) });
                        break;
                    case 2://修改税点
                        count = SaContract.UpdateDirect(p => ids.Contains(p.Id.ToString()), p => new Model.DbModels.Account.Salary { TaxRate = Convert.ToDecimal(data) });
                        break;
                    case 3://修改提成
                        count = SaContract.UpdateDirect(p => ids.Contains(p.Id.ToString()), p => new Model.DbModels.Account.Salary { Percentage = Convert.ToDecimal(data) });
                        break;
                    case 4://修改保底金额
                        count = SaContract.UpdateDirect(p => ids.Contains(p.Id.ToString()), p => new Model.DbModels.Account.Salary { MinAmount = Convert.ToDecimal(data) });
                        break;
                    case 5://修改工资状态
                        SaContract.Repository.UnitOfWork.BeginTransaction();
                        try
                        {
                           
                            foreach (var item in SaContract.Entities.Where(p => p.State == 0 && ids.Contains(p.Id.ToString())).ToList())
                            {
                                switch (item.ModuleID)
                                {
                                    case 1:
                                        item.Amount = (((BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 1).FirstOrDefault().Amount) + (BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 2).FirstOrDefault().Amount) - ((BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 3).FirstOrDefault().Amount) * (1 - item.ReturnRate)) - (BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 4).FirstOrDefault().Amount) - (EContract.Entities.Count(p => p.ModuleID == item.ModuleID && p.RunningsID == item.RunningsID && (p.State == 2 || p.State == 4)) > 0 ? EContract.Entities.Where(p => p.ModuleID == item.ModuleID && p.RunningsID == item.RunningsID && (p.State == 2 || p.State == 4)).Sum(p => p.Amount) : 0)) * (1 - item.TaxRate) * item.Percentage);
                                        if (item.Amount < item.MinAmount)
                                        {
                                            item.Amount = item.MinAmount;
                                        }
                                        break;
                                    case 2:
                                        item.Amount = (((BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 6).FirstOrDefault().Amount) - ((BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 7).FirstOrDefault().Amount) * (1 - item.ReturnRate)) - (EContract.Entities.Count(p => p.ModuleID == item.ModuleID && p.RunningsID == item.RunningsID && (p.State == 2 || p.State == 4)) > 0 ? EContract.Entities.Where(p => p.ModuleID == item.ModuleID && p.RunningsID == item.RunningsID && (p.State == 2 || p.State == 4)).Sum(p => p.Amount) : 0)) * (1 - item.TaxRate) * item.Percentage);
                                        if (item.Amount < item.MinAmount)
                                        {
                                            item.Amount = item.MinAmount;
                                        }
                                        break;
                                    case 4:
                                        item.Amount = (((BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 9).FirstOrDefault().Amount) - ((BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 10).FirstOrDefault().Amount) * (1 - item.ReturnRate)) - (EContract.Entities.Count(p => p.ModuleID == item.ModuleID && p.RunningsID == item.RunningsID && (p.State == 2 || p.State == 4)) > 0 ? EContract.Entities.Where(p => p.ModuleID == item.ModuleID && p.RunningsID == item.RunningsID && (p.State == 2 || p.State == 4)).Sum(p => p.Amount) : 0)) * (1 - item.TaxRate) * item.Percentage);
                                        if (item.Amount < item.MinAmount)
                                        {
                                            item.Amount = item.MinAmount;
                                        }
                                        break;
                                    case 5:
                                        item.Amount = (((BContract.Entities.Where(p => p.RunningsID == item.RunningsID && p.ModuleID == item.ModuleID && p.BrokerageTypeID == 12).FirstOrDefault().Amount) - (EContract.Entities.Count(p => p.ModuleID == item.ModuleID && p.RunningsID == item.RunningsID && (p.State == 2 || p.State == 4)) > 0 ? EContract.Entities.Where(p => p.ModuleID == item.ModuleID && p.RunningsID == item.RunningsID && (p.State == 2 || p.State == 4)).Sum(p => p.Amount) : 0)) * (1 - item.TaxRate) * item.Percentage);
                                        if (item.Amount < item.MinAmount)
                                        {
                                            item.Amount = item.MinAmount;
                                        }
                                        break;
                                    default:
                                        break;
                                }
                                item.State = 1;
                                item.SalaryDate = Convert.ToDateTime(data);
                                SaContract.Update(item);
                            }
                            SaContract.Repository.UnitOfWork.Commit();
                            count = 1;
                        }
                        catch (Exception e)
                        {
                            SaContract.Repository.UnitOfWork.Rollback();
                            count = 0;
                        }
                        break;
                    default:
                        break;
                }
                if (count > 0)
                {
                    result.Type = AjaxResultType.Success;
                    result.Content = "操作成功";
                }
                else
                {
                    result.Type = AjaxResultType.Error;
                    result.Content = "操作失败";
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                result.Type = AjaxResultType.Error;
                result.Content = "异常操作";
            }
            return JsonEx(result);
        }
    }
}